---
import { type CollectionEntry, getCollection } from "astro:content";
import PostDetails from "@layouts/PostDetails.astro";

export interface Props {
  post: CollectionEntry<"posts">;
}

export async function getStaticPaths() {
  const posts = await getCollection("posts");

  const postResult = posts.map(post => ({
    params: { slug: post.slug },
    props: { post },
  }));

  return [...postResult];
}

const { post } = Astro.props;
---

<PostDetails post={post} />
